/**
 * 
 */
package com.cipe.cmrs.controllers.document;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.cipe.cmrs.view.WordPdfView;

/**
 * @author Incepio
 * 
 */
@Controller
public class DocumentController {
    @RequestMapping(value = "/report.do", method = RequestMethod.GET)
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String reportType = request.getParameter("reportType");
        if (!StringUtils.hasText(reportType)) {
            reportType = "Sample Content";
        }
        return new ModelAndView("samplePdfView", "content", reportType);
    }

    @RequestMapping(value = "/openFile.do", method = RequestMethod.GET)
    public ModelAndView openFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String fileName = request.getParameter("fileName");
        return new ModelAndView("wordPdfView", WordPdfView.PARAM_FULL_PATH_NAME, fileName);
    }
}
